package cn.wolfcode.crm.domain;

import cn.wolfcode.crm.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;

@Setter
@Getter
public class Customer extends BaseDomain {
    /*
     * 0:潜在客户
     * 1:客户池
     * 2:开发失败
     * 3:流失
     * */

    public static final Integer POTENTIAL_CUSTOMERS = 0;
    public static final Integer POOL_CUSTOMERS = 1;
    public static final Integer FAILED_CUSTOMERS = 2;
    public static final Integer LOST_CUSTOMERS = 3;
    public static final Integer FORMAL_CUSTOMERS = 4;

    private String name;//客户姓名

    private Integer age;//客户年龄

    private Integer gender;//性别

    private String tel;//电话

    private String qq;//qq

    private Systemdictionaryitem job;//来源数据字典明细,职位

    private Systemdictionaryitem source;//来源数据字典明细,来源

    private Employee seller;//营销人员

    private Employee inputUser;//录入人员

    private Date inputTime;//录入时间

    private Integer status = POTENTIAL_CUSTOMERS;//客户状态

    public String getJson() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("age", age);
        map.put("gender", gender);
        map.put("tel", tel);
        map.put("qq", qq);
        map.put("jobId", job.getId());
        map.put("sellerId", seller.getId());
        map.put("sellerName", seller.getName());
        map.put("sourceId", source.getId());
        return JSONUtil.toJSONString(map);
    }

    public String getGenderName() {
        String gender = null;
        if (this.gender == 0) {
            gender = "女";
        } else if (this.gender == 1) {
            gender = "男";
        }
        return gender;
    }

    public String getStatusName() {
        String status = "潜在客户";
        if (this.status == POOL_CUSTOMERS) {
            status = "客户池";
        } else if (this.status == FAILED_CUSTOMERS) {
            status = "开发失败";
        } else if (this.status == LOST_CUSTOMERS) {
            status = "流失";
        }else if (this.status == FORMAL_CUSTOMERS) {
            status = "正式客户";
        }
        return status;
    }
}